package com.usian.user.controller;


import com.usian.common.Result;
import com.usian.entity.Reviews;
import com.usian.user.service.IReviewsService;
import com.usian.vo.ReviewsVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-01-15
 */
@RestController
@RequestMapping("/user/reviews")
public class ReviewsController {

    @Autowired
    private IReviewsService reviewsService;

    @Operation(summary = "添加评价")
    @PostMapping("/addReviews")
    public Result<String> addReviews(@RequestBody Reviews reviews){
        return reviewsService.addReviews(reviews);
    }

    @Operation(summary = "根据carId查询所有评价")
    @GetMapping("/findReviewsAll/{carId}")
    public Result<List<ReviewsVo>> findReviewsAll(@PathVariable Integer carId){
        return reviewsService.findReviewsAll(carId);
    }

}
